<template>
 <van-tabs :active="tabsActive" @change="tabChange">
    <van-tab title="HOME">
      <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
        <van-swipe-item>1</van-swipe-item>
        <van-swipe-item>2</van-swipe-item>
        <van-swipe-item>3</van-swipe-item>
        <van-swipe-item>4</van-swipe-item>
      </van-swipe>
    </van-tab>
    <van-tab
      v-for="(item, index) in navList"
      :key="index"
      :title="item.title">
      <nav-page :id="item.id" />
    </van-tab>
  </van-tabs>
</template>
<script>
import { computed } from 'vue'
import { useStore } from 'vuex'
import NavPage  from '@/components/NavPage.vue'

export default {
  name: "HomeMain",
  components: {
    NavPage,
  },
  data() {
    return {
      navList: [
        { title: 'Home Textile', id: 1 },
        { title: 'Home Decor', id: 2 },
      ],
    }
  },
  setup() {
    const store = useStore()
    const tabsActive = store.state.home.navIndex
    
    return {
      tabsActive,
      navIndex: computed(() => store.state.home.navIndex)
    }
  },
  methods: {
    tabChange(active) {
      this.$store.commit('home/setNavIndex', active)
    },
  },
}
</script>
<style lang="scss" scoped>
.index {
   .my-swipe .van-swipe-item {
      color: #fff;
      font-size: 20px;
      line-height: 150px;
      text-align: center;
      background-color: #39a9ed;
    }
}
</style>